/**
 * Copyright (c) 2021-2024 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

{% set param_types_list = item.param_types.values() | unique | list %}
{%- if item.method_return_type != "void" %} 
{% set param_types_list = param_types_list + [item.method_return_type] | list %}
{%- endif %}
{%- if item.result_storage is defined %}
{% set param_types_list = param_types_list + [(item.param_types[item.result_storage])] %}
{%- endif %}
{%- if item.expected_test_data_item_type is defined %}
{% set param_types_list = param_types_list + [item.expected_test_data_item_type] %}
{%- endif %}

{%- for value in param_types_list | unique %}
function printData(paramName: String, param: {{.value}}) : void {
{%- if value.endswith('[]') %}
  console.print(paramName)
  console.print(":")
  for (let i = 0 ; i < param.length; i++) {
     console.print(param[i])
     console.print(";")
  }
{% else %}  
  console.print(paramName)
  console.print(":")
  console.print(param)
  console.print(";")
{%- endif %}
  console.println()
}

{%- endfor %}

{%- if item.method_return_type != "void" %}
function printActualData(actual : {{.item.method_return_type}}) : void {
{%- else %}
function printActualData(actual : {{.item.param_types[item.result_storage]}}) : void {
{%- endif %}
  printData("ACTUAL:", actual);  
}

function printExpectedData(expected : {{.item.expected_test_data_item_type}}) : void {
  printData("EXPECTED", expected)
}
